package org.dei.perla.aggregates;

import java.util.Iterator;
import java.util.List;

import org.dei.perla.parser.expressions.ConstantFloat;

public class SampleSum implements AggregationOperator {

	@Override
	public ConstantFloat doOperation(ConstantFloat[] sample) {
		double sum = 0;
		int len = sample.length;
		for (int i = 0; i < len; i++) {
			sum += sample[i].getValueFloat();
		}
		 return new ConstantFloat(sum);
	}

	@Override
	public ConstantFloat doOperation(List<ConstantFloat> sample) {
		double sum = 0;
		Iterator<ConstantFloat> it = sample.iterator();
		while (it.hasNext()) {
			ConstantFloat tConstantFloat = it.next();
			sum += tConstantFloat.getValueFloat();
		}
			return new ConstantFloat(sum);
	}
	

}
